package siruna.WE.core.model.FunctionalBlocks;

import java.util.ArrayList;
import java.util.HashMap;

import org.apache.http.MethodNotSupportedException;

import siruna.WE.core.RSS;
import siruna.WE.core.events.Event;
import siruna.WE.core.model.FunctionalBlock;

public class RssReaderImpl extends FunctionalBlock {

	private ArrayList<HashMap<String, String>> list;

	@Override
	public byte[] toByteArray() throws MethodNotSupportedException {
		throw new MethodNotSupportedException("");
	}

	public RssReaderImpl() {
		super();
		System.out.println("RssReader gemaakt");

	}

	@Override
	public ArrayList<HashMap<String, String>> toList() throws MethodNotSupportedException {

		System.out.println("Rssreader toList");
		return list;
	}

	public void load() {
		
		System.out.println("Rssreader load: "+getId());
		list = RSS.parseFeed(getAttributes().get("url"));
		Event e = new Event(getId(), getAttributes().get(
				"onloaded"), "rss feed is geladen");
		getEventHandler().EventOccured(e);

	}

	@Override
	public String toHTML() {
		// TODO Auto-generated method stub
		return null;
	}

}
